home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nautilus 1994 April
/
Nautilus CD Magazine Volume 4-4 April 1994 Windows Edition.mdf
/
setup
/
nautcd
/
link
/
phone.scr
< prev
next >
Wrap
Text File
|
1993-08-18
|
5KB
|
235 lines
!
! Copyright (c) 1993
! by CompuServe Incorporated, Columbus, Ohio
!
! The information in this software is subject to change without
! notice and should not be construed as a commitment by CompuServe.
!
! PHONE:
! Contains modem/phone related logic.
! Success: returns %Success
! Failure: saves error msg in %FailureMsg and returns %Failure
!
!+V
! "3.1"
!-V
if %DialType = 2 goto Direct_Connect;
WaitTime = 10;
ifndef %mdm_UserID = "";
ifndef %mdm_Password = "";
goto Do_Phone_Connect;
!
! Subroutines
!
Send_Modem_Cmd:
sendm %mdm_Prefix;
sendm ModemStr;
sendm %mdm_Suffix;
End_Modem_Cmd:
return;
Hangup_Before_Connect:
define %LOCAL = 2;
call %Dir & "disconct.scr" () : Result;
return;
Two_Tries_Hangup:
gosub Hangup_Before_Connect;
goto Send_Reset_String;
!
! Main Program: Start_Connect
!
Do_Phone_Connect:
RingLimit = 5;
RingCount = 0;
UsingModem = %FALSE;
on cancel goto Phone_Cancelled;
if %DialType = 0 goto Get_Tone_Str;
DialTypeStr = %mdm_Pulse_Dial; ! Type = DT_Pulse
goto Init_Modem;
Get_Tone_Str:
DialTypeStr = %mdm_Tone_Dial; ! Type = DT_Tone
Init_Modem:
show "Initializing modem";
MsgStr = "Dialing " & %Phone;
tries = 0;
Send_Reset_String:
if (%mdm_Reset = "") goto Modem_OK;
ModemStr = %mdm_Reset;
gosub Send_Modem_Cmd;
Send_Wait:
wait
"User Id" goto Send_User_ID,
"Password" goto Send_Password,
%mdm_Ack goto Modem_OK,
"0" goto Modem_OK
until 40;
tries = tries + 1;
if tries = 2 goto Two_Tries_Hangup; ! Two failures to send Reset -
! hang up and try twice more.
if tries < 4 goto Send_Reset_String;
wait until WaitTime;
FailStr = "Modem not responding";
goto Phone_Failed;
Send_User_ID:
!
! For those modems that support password security...
!
send %mdm_UserID & "^M";
goto Send_Wait;
Send_Password:
!
! For those modems that support password security...
!
send %mdm_Password & "^M";
wait
"User id" goto Modem_Security_Error,
%mdm_Ack goto Send_Reset_String,
"0" goto Send_Reset_String
until 100;
goto Send_Reset_String;
Modem_Security_Error:
define %FailureMsg = "Invalid modem security User ID or password";
exit %Fatal;
Modem_OK:
wait until 10;
if (%mdm_Init = "") goto Check_Modem_Speaker;
sendm %mdm_Init;
wait
%mdm_Ack goto End_Wait1,
"ERROR" goto Show_Error
until 33;
goto End_Wait1;
Show_Error:
show "Error in modem initialization command";
wait until 10;
End_Wait1:
wait until 10;
Check_Modem_Speaker:
if (%mdm_Speaker <> 0) goto Try_Phone;
sendm %mdm_Prefix;
sendm "M0";
send %CR;
wait
%mdm_Ack goto End_Wait2
until 33;
End_Wait2:
wait until 10;
Try_Phone:
count = 0;
FailStr = "";
Dial_Phone:
if (count > %Retry) goto Phone_Failed;
show MsgStr;
ModemStr = DialTypeStr & %Phone;
gosub Send_Modem_Cmd;
Start_Phone_Loop:
wait
%mdm_Success goto Modem_Success,
%mdm_Failure goto Modem_Failure,
"No Dial" goto No_Dial_Tone,
"Dial Complete" goto Dial_Complete,
"Busy" goto Line_Busy,
"Ring" goto Remote_Ring
until 556;
FailStr = "Dialing failed";
goto Exit_Failure;
Modem_Success:
wait until 5;
Direct_Connect:
exit %Success;
Modem_Failure:
FailStr = "Dialing unsuccessful, check phone number";
wait until WaitTime;
goto End_Phone_Loop;
No_Dial_Tone:
FailStr = "No Dial";
goto Exit_Failure;
Dial_Complete:
MsgStr = "Dialed " & %Phone & ", awaiting answer";
show MsgStr;
goto Start_Phone_Loop;
Line_Busy:
FailStr = "Number is busy";
wait until 2 * WaitTime;
send %CR;
wait
%mdm_Success goto End_Line_Busy,
%mdm_Failure goto End_Line_Busy,
"No Dial" goto End_Line_Busy,
"Dial Complete" goto End_Line_Busy,
"Busy" goto End_Line_Busy,
"Ring" goto End_Line_Busy
until 56;
End_Line_Busy:
wait until WaitTime;
goto End_Phone_Loop;
Remote_Ring:
if RingCount <= RingLimit goto Show_Ringing;
FailStr = "No answer";
goto End_Phone_Loop;
Show_Ringing:
MsgStr = %Phone & " is ringing, awaiting answer";
show MsgStr;
goto Start_Phone_Loop;
End_Phone_Loop:
MsgStr = FailStr & ", redialing " & %Phone;
count = count + 1;
goto Dial_Phone;
Phone_Cancelled:
gosub Hangup_Before_Connect;
exit Result;
Phone_Failed:
if FailStr <> "" goto Exit_Fatal;
FailStr = "Dialing failed";
Exit_Fatal:
define %FailureMsg = FailStr;
exit %Fatal;
Exit_Failure:
define %FailureMsg = FailStr;
exit %Failure;